//
// Created by zhupi on 2024/11/4.
//

#include "properts_dialog.h"
#include <QHBoxLayout>
#include <QRadioButton>
#include <QPushButton>

PropertsDialog::PropertsDialog(QWidget *parent) {

}

void PropertsDialog::Initial()
{
    QVBoxLayout *vbox = new QVBoxLayout;

    tabWidte_ = new QTabWidget;
    vbox->addWidget(tabWidte_);
    IntitTable();

    QPushButton *okBt = new QPushButton("ok");
    connect(okBt, &QPushButton::released, this, &PropertsDialog::OKSg);
    vbox->addWidget(okBt);

    this->setLayout(vbox);

    Test();
}

void PropertsDialog::IntitTable() {

    QWidget *widget = new QWidget;

    QVBoxLayout *vbox = new QVBoxLayout;

    QHBoxLayout *hboxBt = new QHBoxLayout;
    QRadioButton *bt1 = new QRadioButton;
    hboxBt->addWidget(bt1);

    vbox->addLayout(hboxBt);
    tableWidget_ =  new TableWidget;
    vbox->addWidget(tableWidget_);


    QHBoxLayout *hbox = new QHBoxLayout;
    QPushButton *button = new QPushButton;
    hbox->addWidget(button);
    vbox->addLayout(hboxBt);

    widget->setLayout(vbox);

    tabWidte_->addTab(widget, "dasdfsafd");
}

void PropertsDialog::Test()
{
    // 创建 TableWidget 实例
//    TableWidget *tableWidget = new TableWidget;

    // 定义测试数据
    std::vector<std::vector<QString>> testData = {
            {"Alice", "Option 1", "25"},
            {"Bob", "Option 2", "30"},
            {"Charlie", "Option 3", "22"},
            {"Diana", "Option 1", "28"},
            {"Eve", "Option 2", "35"}
    };

    // 加载测试数据到表格
    tableWidget_->loadTableData(testData);

//    // 检查数据是否正确加载到缓存（输出到控制台进行验证）
    for (const auto &row : tableWidget_->dataVec) {
        for (const auto &cell : row) {
            qDebug() << cell;
        }
        qDebug() << "----";
    }
}
